package com.bshark.util;

import java.io.UnsupportedEncodingException;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

public class JsonParser {
	private static JSONObject mJson;

	public synchronized static String get(String json, String key) {
		String re = null;
		try {
			mJson = JSON.parseObject(json);
			re = mJson.getString(key);
			mJson =null;
		} catch (Exception e) {

		}
		return re;
	}

	// {handler:"MessageHandler",action:"send",phone:"15013868006",message:"biaoqing<img src="2130837573">"}
	public static void main(String[] args) throws UnsupportedEncodingException {
		//String aaa ="{handler:\"UserHandler\",action:\"sign\",phone:\"+8613420990844\",sys:\"iphone\",tokenid:\"94f331ecbd7e850a6eb50adaca683d7d83956fac19462b3cdc5ba5a30aaf6df9\"}";
		String aaa = "{\"address_language\":\"zh_CN\",\"host\":\"maps.google.com\",\"radio_type\":\"gsm\",\"home_mobile_country_code\":\"460\",\"home_mobile_network_code\":\"01\",\"cell_towers\":[{\"mobile_network_code\":\"01\",\"timing_advance\":5555,\"location_area_code\":42291,\"cell_id\":23347437,\"signal_strength\":-60,\"age\":0,\"mobile_country_code\":\"460\"}],\"request_address\":true,\"version\":\"1.1.0\"}";
		System.out.println(JsonParser.get(aaa, "version"));
	}
}
